import {Component} from 'react'

export default function withHoc(options) {
    return function (WrappendComponent) {
        return class extends Component{
            state = {...options()}
            handleChange(e){
                this.setState({
                    [e.target.name]:e.target.value
                })
            }

            handleSubmit(e){
                e.preventDefault()
                console.log(this.state)
            }
            render() {
                return <WrappendComponent
                    handleChange={this.handleChange.bind(this)}
                    handleSubmit={this.handleSubmit.bind(this)}
                    formData={this.state}/>;
            }
        }
    }
}